package me.algo.str;

import java.util.Objects;

/**
 * @author guozheng
 * @date 2024/4/20
 */
public class S1 {
    public static void main(String[] args) {
        String hello = toLowerCase("Hello").toLowerCase();
        System.out.println(hello);
    }
    /**
     * 709 装换成小写
     * @param s
     * @return
     */
    public static String toLowerCase(String s) {
        if (Objects.isNull(s) || s.isEmpty()) {
            return s;
        }
        char[] chars = new char[s.length()];
        char[] array = s.toCharArray();

        for (int i = 0; i < array.length; i++) {
            char c = array[i];
            if (c >= 'A' && c <= 'Z') {
                chars[i] = (char) ((int) c - 'A' + 'a');
            } else {
                chars[i] = c;
            }
        }
        return String.valueOf(chars);
    }



}
